<?php $this->_extends('_layouts/basic_layout'); ?>

<?php $this->_block('resource'); ?>

<?php $this->_endblock(); ?>

<?php $this->_block('title'); ?>
	Html Templates
<?php $this->_endblock(); ?>

<?php $this->_block('admin_contents'); ?>

<div class="row-fluid">		<!-- sortable ui-sortable -->
	<div class="box span12">
		<div class="box-header well">
			<h2><i class="icon-user"></i> 模板类别</h2>
		</div>
		<div class="box-content">
			<div role="grid" id="area">
				<div class="row-fluid"> 	<!-- sortable ui-sortable -->
					<form class="form-inline" action="<?php echo url('types/htmltemplate', array('ope' => 'add')); ?>" method="post">
						<input type="hidden" name="whichType" value="area" />
						<fieldset>
							<legend>区域分类</legend>
							
							<label class="control-label" for="name">地区(Zh)：</label>
							<input name="name" id="name" type="text" />
							
							<label class="control-label" for="name_en">地区(En)：</label>
							<input name="name_en" id="name_en" type="text" />
							
							<input type="submit" value="添加" class="btn" />
						</fieldset>
					</form>
				</div>
				
				<div class="row-fluid">
					<table class="table table-striped table-bordered">
						<thead>
							<tr role="row">
								<th>地区(Zh)</th>
								<th>地区(En)</th>
								<th>默认值</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<?php if(!empty($htmltemplateTypes['type_area'])): foreach($htmltemplateTypes['type_area'] as $ht_t): ?>
								<tr>
									<td><?php echo $ht_t['name']; ?></td>
									<td><?php echo $ht_t['name_en']; ?></td>
									<td><?php echo ($ht_t['is_default'] == 1)? '是' : ''; ?></td>
									<td>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'delete', 'id' => $ht_t['id'], 'whichType' => 'area')); ?>">删除</a>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'setdefault', 'id' => $ht_t['id'], 'whichType' => 'area')); ?>">设为默认</a>
									</td>
								</tr>
							<?php endforeach; endif; ?>
						</tbody>
					</table>
				</div>
			</div>
			
			
			<div role="grid" id="color">
				<div class="row-fluid"> 	<!-- sortable ui-sortable -->
					<form class="form-inline" action="<?php echo url('types/htmltemplate', array('ope' => 'add')); ?>" method="post">	
						<input type="hidden" name="whichType" value="color" />
						<fieldset>
							<legend>色彩分类</legend>
							<label class="control-label" for="name">颜色名称(Zh)：</label>
							<input name="name" id="name" type="text" />
							
							<label class="control-label" for="name_en">颜色名称(En)：</label>
							<input name="name_en" id="name_en" type="text" />
							
							<label class="control-label" for="name_en">颜色Hex值：</label>
							<input name="color_hex" id="color_hex" type="text" />
							
							<input type="submit" value="添加" class="btn" />
						</fieldset>
					</form>
				</div>
				
				<div class="row-fluid">
					<table class="table table-striped table-bordered">
						<thead>
							<tr role="row">
								<th>颜色名称(Zh)</th>
								<th>颜色名称(En)</th>
								<th>Hex值</th>
								<th>默认值</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<?php if(!empty($htmltemplateTypes['type_color'])): foreach($htmltemplateTypes['type_color'] as $ht_t): ?>
								<tr>
									<td><?php echo $ht_t['name']; ?></td>
									<td><?php echo $ht_t['name_en']; ?></td>
									<td>
										<span style="text-decoration: underline; color: <?php echo $ht_t['color_hex']; ?>;"><?php echo $ht_t['color_hex']; ?></span>
									</td>
									<td><?php echo ($ht_t['is_default'] == 1)? '是' : ''; ?></td>
									<td>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'delete', 'id' => $ht_t['id'], 'whichType' => 'color')); ?>">删除</a>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'setdefault', 'id' => $ht_t['id'], 'whichType' => 'color')); ?>">设为默认</a>
									</td>
								</tr>
							<?php endforeach; endif; ?>
						</tbody>
					</table>
				</div>
			</div>
			
			
			<div role="grid" id="columnwidth">
				<div class="row-fluid"> 	<!-- sortable ui-sortable -->
					<form class="form-inline" action="<?php echo url('types/htmltemplate', array('ope' => 'add')); ?>" method="post">	
						<input type="hidden" name="whichType" value="columnwidth" />
						<fieldset>
							<legend>行列分类</legend>
							<label class="control-label" for="name">名称(Zh)：</label>
							<input name="name" id="name" type="text" />
							
							<label class="control-label" for="name_en">名称(En)：</label>
							<input name="name_en" id="name_en" type="text" />
							
							<input type="submit" value="添加" class="btn" />
						</fieldset>
					</form>
				</div>
				
				<div class="row-fluid">
					<table class="table table-striped table-bordered">
						<thead>
							<tr role="row">
								<th>名称(Zh)</th>
								<th>名称(En)</th>
								<th>默认值</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<?php if(!empty($htmltemplateTypes['type_columnwidth'])): foreach($htmltemplateTypes['type_columnwidth'] as $ht_t): ?>
								<tr>
									<td><?php echo $ht_t['name']; ?></td>
									<td><?php echo $ht_t['name_en']; ?></td>
									<td><?php echo ($ht_t['is_default'] == 1)? '是' : ''; ?></td>
									<td>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'delete', 'id' => $ht_t['id'], 'whichType' => 'columnwidth')); ?>">删除</a>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'setdefault', 'id' => $ht_t['id'], 'whichType' => 'columnwidth')); ?>">设为默认</a>
									</td>
								</tr>
							<?php endforeach; endif; ?>
						</tbody>
					</table>
				</div>
			</div>
			
			<div role="grid" id="sidebarcorner">
				<div class="row-fluid"> 	<!-- sortable ui-sortable -->
					<form class="form-inline" action="<?php echo url('types/htmltemplate', array('ope' => 'add')); ?>" method="post">	
						<input type="hidden" name="whichType" value="sidebarcorner" />
						<fieldset>
							<legend>侧边栏分类</legend>
							<label class="control-label" for="name">名称(Zh)：</label>
							<input name="name" id="name" type="text" />
							
							<label class="control-label" for="name_en">名称(En)：</label>
							<input name="name_en" id="name_en" type="text" />
							
							<input type="submit" value="添加" class="btn" />
						</fieldset>
					</form>
				</div>
				
				<div class="row-fluid">
					<table class="table table-striped table-bordered">
						<thead>
							<tr role="row">
								<th>名称(Zh)</th>
								<th>名称(En)</th>
								<th>默认值</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<?php if(!empty($htmltemplateTypes['type_sidebarcorner'])): foreach($htmltemplateTypes['type_sidebarcorner'] as $ht_t): ?>
								<tr>
									<td><?php echo $ht_t['name']; ?></td>
									<td><?php echo $ht_t['name_en']; ?></td>
									<td><?php echo ($ht_t['is_default'] == 1)? '是' : ''; ?></td>
									<td>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'delete', 'id' => $ht_t['id'], 'whichType' => 'sidebarcorner')); ?>">删除</a>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'setdefault', 'id' => $ht_t['id'], 'whichType' => 'sidebarcorner')); ?>">设为默认</a>
									</td>
								</tr>
							<?php endforeach; endif; ?>
						</tbody>
					</table>
				</div>
			</div>
			
			<div role="grid" id="using">
				<div class="row-fluid"> 	<!-- sortable ui-sortable -->
					<form class="form-inline" action="<?php echo url('types/htmltemplate', array('ope' => 'add')); ?>" method="post">	
						<input type="hidden" name="whichType" value="using" />
						<fieldset>
							<legend>用途分类</legend>
							<label class="control-label" for="name">名称(Zh)：</label>
							<input name="name" id="name" type="text" />
							
							<label class="control-label" for="name_en">名称(En)：</label>
							<input name="name_en" id="name_en" type="text" />
							
							<input type="submit" value="添加" class="btn" />
						</fieldset>
					</form>
				</div>
				
				<div class="row-fluid">
					<table class="table table-striped table-bordered">
						<thead>
							<tr role="row">
								<th>名称(Zh)</th>
								<th>名称(En)</th>
								<th>默认值</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<?php if(!empty($htmltemplateTypes['type_using'])): foreach($htmltemplateTypes['type_using'] as $ht_t): ?>
								<tr>
									<td><?php echo $ht_t['name']; ?></td>
									<td><?php echo $ht_t['name_en']; ?></td>
									<td><?php echo ($ht_t['is_default'] == 1)? '是' : ''; ?></td>
									<td>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'delete', 'id' => $ht_t['id'], 'whichType' => 'using')); ?>">删除</a>
										<a href="<?php echo url('types/htmltemplate', array('ope' => 'setdefault', 'id' => $ht_t['id'], 'whichType' => 'using')); ?>">设为默认</a>
									</td>
								</tr>
							<?php endforeach; endif; ?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>


<?php $formErrors = json_encode($typeModel->getValidateError()); ?>
<script>
	window.location.hash = '<?php echo $whichType; ?>';

	$.each(<?php echo $formErrors; ?>, function(item, errors){
		$.each(errors, function(k, error){
			noty({
				'text': item + ': ' + error,
				'layout': 'topRight',
				'type': 'error'
			});
		});
	});
</script>
<?php $this->_endblock(); ?>